package no.sachmuld.methodcombination.examples.annotation.clossimplestyle.around;

import no.sachmuld.aspectjattach.AspectJAgent;
import no.sachmuld.methodcombination.api.MethodInvocation;

/**
 *
 */
public class Main implements Runnable {

    @Override
    public void run() {

        AspectJAgent.initializeIfNeeded();

        new Runnable()  {

            @Override
            public void run() {

                Foo foo = new Foo();

                foo.with(new PrimaryFooBehaviour() {
                    @Override
                    public int bar() {
                        return 1;
                    }
                });
                foo.with(new PrimaryFooBehaviour() {
                    @Override
                    public int bar() {
                        return 2;
                    }
                });
                foo.with(new AroundFooBehaviour() {
                    @Override
                    public int aroundBar(MethodInvocation<Integer> methodInvocation) {
                        return -methodInvocation.proceed();
                    }
                });

                System.out.println(foo.bar());

            }

        }.run();

    }

    public static void main(String... args) {

        new Main().run();

    }
}
